version: "3.7"

services:
    caddy:
        image: caddy:2-alpine
        restart: always
        ports:
            - "80:80"
            - "443:443"
            - "443:443/udp"
        volumes:
            - ./volumes/caches/caddy/data:/data
            - ./volumes/caches/caddy/config:/config
            - ./volumes/srv/webroot:/srv
        configs:
            - source: caddy
              target: /etc/caddy/Caddyfile
        environment:
            TZ: "${TZ:?define TZ to your timezone, for example: Africa/Gaborone. Refer to https://en.wikipedia.org/wiki/List_of_tz_database_time_zones for documentation}"
            DOMAIN_NAMES: "${DOMAIN_NAMES:?define DOMAIN_NAMES to space-separated list of domains for Caddy configuration}"
    mariadb:
        image: mariadb:lts
        restart: always
        environment:
            TZ: "${TZ}"
            MARIADB_ROOT_PASSWORD: "${DB_PASSWORD:?define DB_PASSWORD environment variable}"
            MARIADB_USER: "${DB_USER:?define DB_USER environment variable.}"
            MARIADB_PASSWORD: "${DB_PASSWORD}"
            MARIADB_DATABASE: "${DB_USER}"
        volumes:
            - ./volumes/db:/var/lib/mysql
    php:
        image: bitnami/php-fpm:8.2
        environment:
            TZ: "${TZ}"
        volumes:
            - ./volumes/srv:/srv
        configs:
            - source: php
              target: /opt/bitnami/php/etc/conf.d/custom.ini
    backupper:
        build: ./docker/backupper
        environment:
            TZ: "${TZ}"
        volumes:
            - .:/data
        configs:
            - source: backupper
              target: /etc/cron.d/main
configs:
    php:
        file: ./configs/php-fpm/php.ini
    caddy:
        file: ./configs/caddy/Caddyfile
    backupper:
        file: ./configs/backupper/main
